import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/home/home.vue'
import Cart from '../views/cart/cart.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/searchResult/:keyword',
    name: 'searchResult',
    component: () => import('./../views/search/result.vue'),
    meta: {
      hidden: true
    }
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('./../views/search/search.vue'),
    meta: {
      hidden: true
    }
  },
  {
    path: '/order4/:item',
    name: 'order4',
    component: () => import('./../views/order/order4.vue'),
    meta: {
      hidden: true
    }
  },
  {
    path: '/order3',
    name: 'order3',
    component: () => import('./../views/order/order3.vue'),
    meta: {
      hidden: true
    }
  },
  {
    path: '/order2/:time/:id',
    name: 'order2',
    component: () => import('./../views/order/order2.vue'),
    meta: {
      hidden: true
    }
  },
  {
    path: '/order/:addressid',
    name: 'order',
    component: () => import('./../views/order/order.vue'),
    meta: {
      hidden: true
    }
  },
  {
    path: '/test',
    name: 'test',
    component: () => import('./../views/test1/test.vue')
  },
  {
    path: '/detail/:proid',
    name: 'detail',
    component: () => import('./../views/detail/detail.vue'),
    meta: {
      hidden: true
    }
  },
  {
    path: '',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home', // 命名路由
    component: Home // 先引入后调用
  },
  {
    path: '/kind',
    name: 'kind',
    component: () => import(/* webpackChunkName: "kind" */ '../views/kind/kind.vue')
  },
  {
    path: '/cart',
    name: './cart',
    component: Cart
    // component: () => import(/* webpackChunkName: "kind" */ '../views/cart/cart.vue')
  },
  {
    path: '/user',
    name: 'user',
    component: () => import(/* webpackChunkName: "kind" */ '../views/user/user.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "kind" */ '../views/login/login.vue'),
    meta: {
      hidden: true
    }
  },
  {
    path: '/step0',
    name: 'register0',
    redirect: '/step0/step1',
    component: () => import(/* webpackChunkName: "reg0" */ '../views/register/reg0.vue'),
    meta: {
      hidden: true
    },
    children: [
      {
        path: 'step1',
        name: 'register1',
        component: () => import(/* webpackChunkName: "reg1" */ '../views/register/reg1.vue'),
        meta: {
          hidden: true
        }
      },
      {
        path: 'step2',
        name: 'register2',
        component: () => import(/* webpackChunkName: "reg1" */ '../views/register/reg2.vue'),
        meta: {
          hidden: true
        }
      },
      {
        path: 'step3',
        name: 'register3',
        component: () => import(/* webpackChunkName: "reg1" */ '../views/register/reg3.vue'),
        meta: {
          hidden: true
        }
      }
    ]
  },
  {
    path: '*',
    name: 'error',
    component: () => import(/* webpackChunkName: "kind" */ '../views/error/error.vue')
  }
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
